home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
usr
/
include
/
sys
/
quota.h.z
/
quota.h
Wrap
C/C++ Source or Header
|
1992-04-03
|
6KB
|
145 lines
#ifndef __SYS_QUOTA_H__
#define __SYS_QUOTA_H__
/**************************************************************************
* *
* Copyright (C) 1989, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
/*
* Various junk to do with various quotas (etc) imposed upon
* the average user (big brother finally hits UNIX).
*/
/*
* The following constants define the default amount of time given a user
* before the soft limits are treated as hard limits (usually resulting
* in an allocation failure). These may be modified by the quotactl
* system call with the Q_SETQLIM or Q_SETQUOTA commands.
*/
#define DQ_FTIMELIMIT (7 * 24*60*60) /* 1 week */
#define DQ_BTIMELIMIT (7 * 24*60*60) /* 1 week */
/*
* There is one quota file per file system and the dqblk structure
* defines the format of an entry for one user in the disk quota file
* (as it appears on disk). This index into the file for a particular uid
* is calculated by qt_dqoff(). This had to change from Berkeley/Sun's
* implementation since EFS does not support holes in files.
* In the kernel, we keep track of the quotas in basic blocks (512 bytes),
* All user commands obtain numbers in bbs from the kernel, but display
* and manipulate figures in kbytes.
*/
struct dqblk {
u_long dqb_bhardlimit; /* absolute limit on disk blks alloc */
u_long dqb_bsoftlimit; /* preferred limit on disk blks */
u_long dqb_curblocks; /* current block count */
u_long dqb_fhardlimit; /* maximum # allocated files + 1 */
u_long dqb_fsoftlimit; /* preferred file limit */
u_long dqb_curfiles; /* current # allocated files */
u_long dqb_btimelimit; /* timer when usage exceeds disk blks limit */
u_long dqb_ftimelimit; /* timer when usage exceeds file limit */
};
/*
* Definitions for the 'quotactl' system call.
*/
#define Q_QUOTAON 1 /* turn quotas on */
#define Q_QUOTAOFF 2 /* turn quotas off */
#define Q_SETQUOTA 3 /* set disk limits & usage */
#define Q_GETQUOTA 4 /* get disk limits & usage */
#define Q_SETQLIM 5 /* set disk limits only */
#define Q_SYNC 6 /* update disk copy of quota usages */
#define Q_ACTIVATE 7 /* update quotas without enabling */
/*
* The quota file has a header, followed by an index
* (list of uids), followed by the on-disk quota information which is
* kept for those users that have quotas. The index size lies in the range
* Q_MININDEX-Q_MAXINDEX. The header has a magic number, followed by the
* quota file index size and then the number of users whose uids appear
* in the index.
*/
struct qt_header {
u_short qh_magic; /* quota file magic number */
u_short qh_index; /* quota file index size */
u_short qh_nusers; /* number of users in this quota file */
u_short qh_uid[1]; /* list of uid's. 0 is always the first one */
};
#define Q_HEADER (sizeof(struct qt_header)-sizeof(u_short))
#define Q_MININDEX 4096 /* min index size for quotas file */
#define Q_MAXINDEX 4096*10 /* max index size for quotas file */
#define Q_MAGIC 0x8765 /* magic number */
#define Q_MAXUSERS ((Q_MAXINDEX - Q_HEADER)/sizeof(u_short))
#ifndef _KERNEL
extern int quotactl(int, caddr_t , int, caddr_t);
#endif /* !_KERNEL */
#ifdef _KERNEL
/*
* The incore dquot structure records disk usage for a user on a filesystem.
* A cache is kept of recently used entries. Active inodes with quotas
* associated with them have a pointer to a incore dquot structure.
*/
struct dquot {
struct dquot *dq_forw, *dq_back;/* hash list, MUST be first entry */
struct dquot *dq_freef, *dq_freeb; /* free list */
u_short dq_flags;
#define DQ_MOD 0x01 /* this quota modified since read */
u_short dq_cnt; /* count of active references */
u_short dq_uid; /* user this applies to */
ulong dq_off; /* offset into quotas file */
struct mount *dq_mp; /* filesystem this relates to */
struct dqblk dq_dqb; /* actual usage & quotas */
sema_t dq_sema; /* semaphore for quota lock */
};
#define dq_bhardlimit dq_dqb.dqb_bhardlimit
#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
#define dq_curblocks dq_dqb.dqb_curblocks
#define dq_fhardlimit dq_dqb.dqb_fhardlimit
#define dq_fsoftlimit dq_dqb.dqb_fsoftlimit
#define dq_curfiles dq_dqb.dqb_curfiles
#define dq_btimelimit dq_dqb.dqb_btimelimit
#define dq_ftimelimit dq_dqb.dqb_ftimelimit
extern struct dquot *qt_getinoquota(struct inode *ip);
extern int qt_chkdq(struct inode *ip, long change, int force, int *spaceleft);
extern int qt_chkiq(struct mount *mp, struct inode *ip, u_int uid, int force);
extern void qt_dqrele(struct dquot *dqp);
extern int qt_closedq(struct mount *mp, int umounting);
extern void qt_dqput(struct dquot *dqp);
extern void qt_dqupdate(struct dquot *dqp);
extern void qt_dqinval(struct dquot *dqp);
extern int qt_getdiskquota(u_int uid, struct mount *mp, int allocate,
struct dquot **dqpp);
extern struct dquot dqfreelist; /* start of the free list */
extern struct dquot *dquot; /* start of the incore quota table */
#define qfree_sema (dqfreelist.dq_sema)
#define DQLOCK(dqp) { \
psema(&(dqp)->dq_sema, PZERO); \
ASSERT(valusema(&(dqp)->dq_sema) <= 0); \
}
#define DQUNLOCK(dqp) { \
ASSERT(valusema(&(dqp)->dq_sema) <= 0); \
vsema(&(dqp)->dq_sema); \
}
#endif /* _KERNEL */
#endif /* __SYS_QUOTA_H__ */